package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.app.entity.VideoCategoryEntity;
import io.renren.modules.app.service.VideoCategoryService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 *
 *
 * @author huangjx
 * @email 1157837249@qq.com
 * @date 2021-04-30 16:55:56
 */
@RestController
@RequestMapping("app/videocategory")
public class VideoCategoryController {
  @Autowired
  private VideoCategoryService videoCategoryService;

  /**
   * 列表
   */
  @RequestMapping("/list")
  @RequiresPermissions("app:videocategory:list")
  public R list(@RequestParam Map<String, Object> params){
    PageUtils page = videoCategoryService.queryPage(params);

    return R.ok().put("page", page);
  }


  /**
   * 信息
   */
  @RequestMapping("/info/{categoryId}")
  @RequiresPermissions("app:videocategory:info")
  public R info(@PathVariable("categoryId") Integer categoryId){
    VideoCategoryEntity videoCategory = videoCategoryService.getById(categoryId);

    return R.ok().put("videoCategory", videoCategory);
  }

  /**
   * 保存
   */
  @RequestMapping("/save")
  @RequiresPermissions("app:videocategory:save")
  public R save(@RequestBody VideoCategoryEntity videoCategory){
    videoCategoryService.save(videoCategory);

    return R.ok();
  }

  /**
   * 修改
   */
  @RequestMapping("/update")
  @RequiresPermissions("app:videocategory:update")
  public R update(@RequestBody VideoCategoryEntity videoCategory){
    videoCategoryService.updateById(videoCategory);

    return R.ok();
  }

  /**
   * 删除
   */
  @RequestMapping("/delete")
  @RequiresPermissions("app:videocategory:delete")
  public R delete(@RequestBody Integer[] categoryIds){
    videoCategoryService.removeByIds(Arrays.asList(categoryIds));

    return R.ok();
  }

}
